package example.chapter7;

import java.io.File;

import com.opensymphony.xwork2.ActionSupport;

public class MultiUploadUsingArrayAction extends ActionSupport{
	private File[] upload;
	private String[] uploadFileName;
	private String[] uploadContentType;
	private String[] serverFullPath;
	
	public String execute() throws Exception{
		
		String basePath = getText("path.upload_file");
		FileService fileService = new FileService();
		
		serverFullPath = new String[upload.length];
		
		for(int i = 0; i < upload.length; i++){
			serverFullPath[i] = fileService.saveFile(upload[i], basePath, uploadFileName[i]);
			System.out.println("serverFullPath[" + i + "] : > " + serverFullPath[i]);
		}
		
		return SUCCESS;
	}

	public File[] getUpload() {
		return upload;
	}

	public void setUpload(File[] upload) {
		this.upload = upload;
	}

	public String[] getUploadFileName() {
		return uploadFileName;
	}

	public void setUploadFileName(String[] uploadFileName) {
		this.uploadFileName = uploadFileName;
	}

	public String[] getUploadContentType() {
		return uploadContentType;
	}

	public void setUploadContentType(String[] uploadContentType) {
		this.uploadContentType = uploadContentType;
	}

	public String[] getServerFullPath() {
		return serverFullPath;
	}

	public void setServerFullPath(String[] serverFullPath) {
		this.serverFullPath = serverFullPath;
	}
	
}
